import time

from common.base import Base,By
from common.functions import open_browser


class LogonPage(Base):
    logon_url = 'http://139.129.26.163/user.php?act=register'

    def __init__(self, browser):
        super().__init__(browser)
        self.user = None

    def input_username(self,username):
        self.find_ele((By.ID,'username')).send_keys(username)

    def input_email(self,email):
        self.find_ele((By.ID,'email')).send_keys(email)

    def input_password(self,password):
        self.find_ele((By.ID,'password1')).send_keys(password)

    def input_password1(self,password):
        self.find_ele((By.ID,'conform_password')).send_keys(password)

    def input_tel(self,tel):
        self.find_ele((By.NAME,'extend_field5')).send_keys(tel)


    def submit(self):
        self.find_ele((By.CLASS_NAME,'us_Submit_reg')).click()

if __name__ == '__main__':
    browser = open_browser()
    logon = LogonPage(browser)
    logon.get('http://139.129.26.163/user.php?act=register')
    logon.input_username('iyy2')
    logon.input_email('222@qq.com')
    logon.input_password('123456')
    logon.input_password1('123456')
    logon.input_tel('111111111111')
    logon.submit()
    time.sleep(2)
    logon.quit()

